package cn.chuanw.db.service;

import cn.chuanw.db.domain.WRenovationRecord;
import cn.chuanw.db.domain.WRenovationRecordExample;
import com.github.pagehelper.PageHelper;
import cn.chuanw.db.dao.WRenovationRecordMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

@Service
public class WRenovationRecordService {
    @Resource
    private WRenovationRecordMapper wRenovationRecordMapper;
   
    public List<WRenovationRecord> querySelective(String houseId, Integer costType, Integer page, Integer size) {
    	WRenovationRecordExample wRenovationRecordExample = new WRenovationRecordExample();
    	WRenovationRecordExample.Criteria criteria = wRenovationRecordExample.createCriteria();

        if (!StringUtils.isEmpty(houseId)) {
            criteria.andHouseIdEqualTo(houseId);
        }

        if (!StringUtils.isEmpty(costType)) {
            criteria.andCostTypeEqualTo(costType);
        }
        criteria.andDelFlagEqualTo(0);
        PageHelper.startPage(page, size);
        return wRenovationRecordMapper.selectByExample(wRenovationRecordExample);
    }

    public void addWHouseInfo(WRenovationRecord wRenovationRecord) {
    	wRenovationRecordMapper.insertSelective(wRenovationRecord);
    }

    public int updateById(WRenovationRecord wRenovationRecord) {
        return wRenovationRecordMapper.updateByPrimaryKeySelective(wRenovationRecord);
    }

}
